
/* Table initialisation */


function loadLadderDataTable(matchmodeID, section, general){
	l("Start loadLadderData");
	l("Matchmode: "+matchmodeID);
	
	resultDivID = "#"+section+"Tabs"+matchmodeID;
	steamID = getParameterByName("ID");
	 $(resultDivID).block({ message: null });
	
	 if(general == 1){
		 $.ajax({
				url : 'ajax.php',
				type : "POST",
				dataType : 'json',
				data : {
					type : "ladder",
					mode : "getGeneralLadderPlayers",
					reload: general,
					ID: steamID
				},
				success : function(result) {
					l(result);
					$(resultDivID).html(result.table);
					
					startDataNumber = result.startDataNumber;
					
					initTable(startDataNumber);
					$.unblockUI;
				}
			});
	 }
	 else{
		 $.ajax({
				url : 'ajax.php',
				type : "POST",
				dataType : 'json',
				data : {
					type : "ladder",
					mode : "loadLadderDataTable",
					MatchModeID: matchmodeID,
					ID: steamID
				},
				success : function(result) {
					l(result);
					$(resultDivID).html(result.table);
					startDataNumber = result.startDataNumber;
					initTable(startDataNumber);
					$.unblockUI;
				}
			});
	 }
	
	
	l("End loadLadderData");
}

function initTable(startDataNumber){
    
    if($(".LadderTable").length > 0){
           $('.LadderTable').dataTable( {
        "sPaginationType": "full_numbers",
         "aaSorting": [[ 2, "desc" ]],
         "aoColumnDefs": [
                          { 'bSortable': false, 'aTargets': [ 1 ] }
                       ],
         "bDestroy": true,
         "iDisplayStart": startDataNumber,
         
        "oLanguage": {
            "sLengthMenu": "_MENU_ Players per page",
            "sInfo": "Showing _START_ to _END_ of _TOTAL_ Players"
        }
         } );
    }
	
}